package org.dromara.web.controller.business;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import org.dromara.web.domain.vo.RemoveRequest;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.dao.business.domain.GreenWord;
import org.dromara.dao.business.domain.GreenWordQuery;
import org.dromara.web.service.business.GreenWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.dromara.common.mybatis.core.page.TableDataInfo;


/**
 * 敏感词检测 控制器
 *
 * @date 2025-04-16 10:07:50
 */
@Validated
@RestController
@RequestMapping("/user/greenWord")
public class GreenWordController extends BaseController {

    @Autowired
    private GreenWordService greenWordService;

    /**
     * 查询敏感词检测列表
     * @SaCheckPermission("user:greenWord:list")
     */

    @GetMapping("/list")
    public TableDataInfo<GreenWord> list(GreenWordQuery query, PageQuery pageQuery) {
        return greenWordService.queryPageList(query, pageQuery);
    }




    /**
     * 获取敏感词检测详细信息
     *
     * @param id 主键
     * @SaCheckPermission("user:greenWord:query")
     */
    @GetMapping("/info")
    public R<GreenWord> getInfo(@NotNull(message = "主键不能为空")
                                     @RequestParam Long id) {
        return R.ok(greenWordService.queryById(id));
    }

    /**
     * 新增敏感词检测
     * @SaCheckPermission("user:greenWord}:add")
     */

    @Log(title = "敏感词检测", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/add")
    public R<Void> add( @RequestBody GreenWord entity) {
        greenWordService.insert(entity);
        return R.ok();
    }

    /**
     * 修改敏感词检测
     * @SaCheckPermission("user:greenWord:edit")
     */

    @Log(title = "敏感词检测", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/update")
    public R<Void> edit( @RequestBody GreenWord update) {
        greenWordService.updateById(update);
        return R.ok();
    }

    /**
     * 删除敏感词检测
     *
     * @param req 主键串
     * @SaCheckPermission("user:greenWord:remove")
     */

    @Log(title = "敏感词检测", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public R<Void> remove(@RequestBody RemoveRequest req) {
        greenWordService.deleteByIds(req.getIds());
        return R.ok();
    }
}
